home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Sound / A-Law sdec⁄scom / ComponentDispatch.h < prev   
Encoding:
Text File  |  1997-06-18  |  7.5 KB  |  162 lines  |  [TEXT/CWIE]

  1. /*
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    Header for common routines for dispatching for a sound component
  5. **
  6. **    by Mark Cookson, Apple Developer Technical Support
  7. **
  8. **    File:    ComponentDispatch.h
  9. **
  10. **    Copyright ©1996 Apple Computer, Inc.
  11. **    All rights reserved.
  12. **
  13. **    You may incorporate this sample code into your applications without
  14. **    restriction, though the sample code has been provided "AS IS" and the
  15. **    responsibility for its operation is 100% yours.  However, what you are
  16. **    not permitted to do is to redistribute the source as "Apple Sample
  17. **    Code" after having made changes. If you're going to re-distribute the
  18. **    source, we require that you make it clear in the source that the code
  19. **    was descended from Apple Sample Code, but that you've made changes.
  20. */
  21.  
  22. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  23. //    Sound Component Function Prototypes
  24.  
  25. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  26. // component stuff
  27.  
  28. static pascal ComponentResult __SoundComponentOpen(void *unused1, ComponentInstance self);
  29. static pascal ComponentResult __SoundComponentClose(SoundComponentGlobalsPtr globals, ComponentInstance self);
  30. static pascal ComponentResult __SoundComponentRegister(SoundComponentGlobalsPtr globals);
  31. static pascal ComponentResult __SoundComponentCanDo(void *unused1, short selector);
  32.  
  33. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  34. // basic stuff
  35.  
  36. static pascal ComponentResult __SoundComponentSetSource(SoundComponentGlobalsPtr globals, SoundSource sourceID, ComponentInstance source);
  37. static pascal ComponentResult __SoundComponentGetSourceData(SoundComponentGlobalsPtr globals, SoundComponentDataPtr *sourceData);
  38. static pascal ComponentResult __SoundComponentSetOutput(SoundComponentGlobalsPtr globals, SoundComponentDataPtr requested, SoundComponentDataPtr *actual);
  39.  
  40. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  41. // info methods
  42.  
  43. static pascal ComponentResult __SoundComponentGetInfo(SoundComponentGlobalsPtr globals, SoundSource sourceID, OSType selector, void *infoPtr);
  44.  
  45. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  46. // control methods
  47.  
  48. static pascal ComponentResult __SoundComponentStopSource(SoundComponentGlobalsPtr globals, short count, SoundSource *sources);
  49. static pascal ComponentResult __SoundComponentPlaySourceBuffer(SoundComponentGlobalsPtr globals, SoundSource sourceID, SoundParamBlockPtr pb, long actions);
  50.  
  51. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  52. // types
  53. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  54.  
  55. #if GENERATINGPOWERPC
  56.  
  57. // These structs are use in PowerMac builds to cast the
  58. // ComponentParameters passed into our component's entry point.
  59.  
  60. enum {
  61.     uppSoundComponentEntryPointProcInfo = kPascalStackBased
  62.         | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  63.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ComponentParameters *)))
  64.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(void *)))
  65. };
  66.  
  67. // These are used to create the routine descriptor to call each function.
  68.  
  69. enum {
  70.         upp__SoundComponentOpenProcInfo = kPascalStackBased
  71.                 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  72.                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(void *)))
  73.                 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(ComponentInstance)))
  74. };
  75.  
  76. enum {
  77.         upp__SoundComponentCloseProcInfo = kPascalStackBased
  78.                 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  79.                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
  80.                 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(ComponentInstance)))
  81. };
  82.  
  83. enum {
  84.         upp__SoundComponentRegisterProcInfo = kPascalStackBased
  85.                 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  86.                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
  87. };
  88.  
  89. enum {
  90.         upp__SoundComponentSetSourceProcInfo = kPascalStackBased
  91.                 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  92.                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
  93.                 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SoundSource)))
  94.                 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(ComponentInstance)))
  95. };
  96.  
  97. enum {
  98.         upp__SoundComponentGetSourceDataProcInfo = kPascalStackBased
  99.                 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  100.                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
  101.                 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SoundComponentDataPtr)))
  102. };
  103.  
  104. enum {
  105.         upp__SoundComponentSetOutputProcInfo = kPascalStackBased
  106.                 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  107.                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
  108.                 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SoundComponentDataPtr)))
  109.                 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(SoundComponentDataPtr)))
  110. };
  111.  
  112. enum {
  113.         upp__SoundComponentGetInfoProcInfo = kPascalStackBased
  114.                 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  115.                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
  116.                 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SoundSource)))
  117.                 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(OSType)))
  118.                 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(void *)))
  119. };
  120.  
  121. enum {
  122.         upp__SoundComponentStopSourceProcInfo = kPascalStackBased
  123.                 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  124.                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
  125.                 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  126.                 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(SoundSource)))
  127. };
  128.  
  129. enum {
  130.         upp__SoundComponentPlaySourceBufferProcInfo = kPascalStackBased
  131.                 | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  132.                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundComponentGlobalsPtr)))
  133.                 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SoundSource)))
  134.                 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(SoundParamBlockPtr)))
  135.                 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
  136. };
  137.  
  138. #define CallComponentFunctionWithStorageUniv(storage, params, funcName) \
  139.         CallComponentFunctionWithStorage(storage, params, &funcName##RD)
  140. #define CallComponentFunctionUniv(params, funcName) \
  141.         CallComponentFunction(params, &funcName##RD)
  142. #define INSTANTIATE_ROUTINE_DESCRIPTOR(funcName) RoutineDescriptor funcName##RD = \
  143.         BUILD_ROUTINE_DESCRIPTOR (upp##funcName##ProcInfo, funcName)
  144.  
  145. INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentRegister);
  146. INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentClose);
  147. INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentOpen);
  148. INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentSetSource);
  149. INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentGetSourceData);
  150. INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentSetOutput);
  151. INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentGetInfo);
  152. INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentStopSource);
  153. INSTANTIATE_ROUTINE_DESCRIPTOR(__SoundComponentPlaySourceBuffer);
  154.  
  155. #else //GENERATING68K
  156.  
  157. #define CallComponentFunctionWithStorageUniv(storage, params, funcName) \
  158.         CallComponentFunctionWithStorage(storage, params, (ComponentFunctionUPP)funcName)
  159. #define CallComponentFunctionUniv(params, funcName) \
  160.         CallComponentFunction(params, (ComponentFunctionUPP)funcName)
  161. #endif
  162.